
#include "nane/core/crt/LogManager.h"
#include "nane/core/crt/LogManagerImpl_.h"
#include <cassert>

namespace nane
{
    ////////////////////////////////////////////////////////////////////////////
    template<>
    ILogSystem* Holder<ILogSystem>::s_instance = NULL;
    ////////////////////////////////////////////////////////////////////////////
    bool LogManager::Initialize( bool _enableStdLogger )
    {
        assert( m_context );
        assert( m_context->logSystem == NULL );
        nane::m_context->logSystem = new Implementation(_enableStdLogger);
        if( nane::m_context->logSystem->Initialize() == false )
        {
            Shutdown();
        }
        return nane::m_context->logSystem != NULL;
    }
    ////////////////////////////////////////////////////////////////////////////
    void LogManager::Shutdown()
    {
        if( nane::m_context->logSystem != NULL )
        {
            nane::m_context->logSystem->Shutdown();
        }
        delete static_cast<Implementation*>(nane::m_context->logSystem);
        nane::m_context->logSystem = NULL;
        Holder<ILogSystem>::Clear();
    }
    ////////////////////////////////////////////////////////////////////////////
}   // namespace nane
